package com.huike.web.controller.system;

import com.huike.clues.domain.SysNotice;
import com.huike.clues.mapper.ISysNoticeMapper;
import com.huike.clues.service.ISysNoticeService;
import com.huike.common.core.controller.BaseController;
import com.huike.common.core.domain.AjaxResult;
import com.huike.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description TODO
 * @Author yy
 * @Date 2023-07-11 23:52
 */

@Slf4j
@RequestMapping("/system/notice")
@RestController
@Api(tags = "通知公告相关接口")
public class SysNoticeController extends BaseController {
    @Resource
    private ISysNoticeService iSysNoticeService;


    /**
     * 获取系统提醒下拉列表
     * @param status
     * @return
     */
    @GetMapping("/list/{status}")
    @ApiOperation("获取系统提醒下拉列表")
    public AjaxResult<List<SysNotice>> NoticeList(@PathVariable String status) {
        log.info("获取系统提醒下拉列表");
        List<SysNotice> list = iSysNoticeService.NoticeList(status);
        return AjaxResult.success(list);
    }


    @GetMapping("/pagelist/{status}")
    public TableDataInfo pageList( @PathVariable String status){
        log.info("获取系统提醒分页列表:{}",status);
        List<SysNotice> sysNoticeList = iSysNoticeService.pageList(status);
        TableDataInfo dataTable = getDataTable(sysNoticeList);
        return dataTable;

    }

    /**
     * 获取详情信息
     * @param noticeId
     * @return
     */
    @ApiOperation("获取详情信息")
    @GetMapping("/noticeId")
    public AjaxResult<SysNotice> noticeId(@PathVariable Integer noticeId){
        log.info("获取详情信息",noticeId);
        SysNotice sysNotice = iSysNoticeService.noticeId(noticeId);
        return AjaxResult.success(sysNotice);
    }

    /**
     * 未读变已读
     * @param noticeId
     * @return
     */
    @ApiOperation("未读变已读")
    @GetMapping("/{noticeId}")
    public AjaxResult noticeById(@PathVariable Integer noticeId){
        log.info("未读变已读",noticeId);
        iSysNoticeService.noticeById(noticeId);
        return AjaxResult.success();
    }
}
